A developer listed as “The BeSly Team” recently posted a new version of aspell, an Open Source spell checking application/library. While aspell support has been integrated into several GUI programs on other platforms (the GAIM instant messaging client, for instance), the BeOS port of aspell is a command line tool. The recent update of the port reminded me that there are a few relatively simple ways to make use of this handy tool without resorting to the terminal – read on for a few tips and tricks for combining aspell with the GUIey goodness of BeOS.

&nbsp

As mentioned in the intro, aspell is a command line tool – so, in order to spell check a file, you need to run a terminal command such as “aspell check filename.txt”. While it’s incredibly useful for spell checking text files from a terminal, most of us are accustomed to spell checkers built into the applications we use to write the text in the first place. It feels a bit cumbersome to save a file, open a terminal, navigate to the file’s location, and then run a command to spell check it. The program is also a library, so developers can make use of aspell in their own programs, but that isn’t of much immediate benefit to those of us who aren’t developers. Fortunately, there are two straightforward methods for making aspell more convenient to use from GUI-land.

Pe Extensiondownload
Pe, the “Programmer’s Editor,” has a plugin mechanism called “extensions.” Third-party developers can easily add functionality to Pe by writing an extension – Pe includes several handy extensions by default, including the indispensable “Prefix Lines” tool. What makes it especially flexible is that extensions can be written as C++ applications or as shell scripts – so even non-programmers like me can write extensions.

Because of Pe’s extensibility, it is possible to write a shell script that runs aspell on the current file. To do so, you first need to create a new text file using Pe or another editor, and then paste in the code below:

#!/bin/sh
Terminal -t "Checking $PE_CUR_FILE" /boot/apps/aspell/aspell check "$PE_CUR_FILE"

You may need to change the code if you installed aspell somewhere other than /boot/apps/aspell. Save the file and call it something like “Check Spelling.” Now you need to move it into the Pe Extensions folder – this is located inside Pe’s application folder, usually found in /boot/apps/Pe/Extensions or /boot/apps/Hekkelman/Pe/Extensions. Lastly, the file needs to be given execute permissions – to do that, right-click on it, select “Get Info,” and then (in the Info window) click the triangle next to the word “Permissions.” Click on all the checkboxes in the bottom row (the row that starts with the word “Execute) and then close the Info window.

Now you should be ready to test the extension. Open up a text file in Pe, click the “Extensions” menu, and you should see an item called “Check Spelling” – click on it. A terminal window will open with aspell, which should then begin spell checking your file. The usage of apsell is pretty straightforward, there is a row of help text along the bottom which lists the keyboard commands to ignore a spelling mistake, or replace a mistake, or add it to your dictionary, etc. When you are finished, the terminal window will close, returning you to Pe, and there will be a dialogue informing you that changes have been made to the file and asking if you would like to reload it. Click “Reload” and you can view the corrections you made with aspell.

For those who would prefer to use a ready-made extension, I’ve uploaded a zip file which you can download here. To install, simply unzip the file and move it to the Extensions folder inside Pe’s application folder – usually located in /boot/apps/Pe/.

Tip:

When aspell displays a word that it thinks is a spelling error, it displays the entire line that the word is located on. If you wrote the file in a text editor that contains a “soft wrapping” option (such as Pe), then a single line may consist of an entire paragraph. This can make it tricky to spot the specific error that aspell has caught. The best way around this is to “Select All” text and use Pe’s “Insert Line Breaks” command (in the “Text” menu), which will convert the soft wrapping into hard line breaks. Once you have finished spell checking the file and have reloaded it in Pe, you can reverse that operation by selecting all the text in the file and using Pe’s “Remove Line Breaks” command (also in the “Text” menu).

Historical Anecdote / Credits:

The idea wasn’t originally mine, the extension is indirectly based on an Ispell extension that was available on the Pe website back in the days days when Maarten Hekkleman was still developing it. I say “indirectly” because I originally used the Ispell extension as inspiration for creating a graphical Word Count extension for Pe (which was itself inspired by a portion of Neal Stephenson’s excellent book/essay In The Beginning Was The Command Line). I was never able to find a working version of Ispell for BeOS, but eventually modified the GUI word count script to create an aspell extension when aspell was first ported to BeOS.

ZooKeeper / XIcon Shortcutdownload
If you’re not a regular user of Pe, but still want to periodically spell check text files created in an app like StyledEdit or HotEdit, it’s also possible to create a shortcut icon – and when a file is dragged-n-dropped onto the icon, it will be sent to aspell. There are two BeOS programs which allow that functionality – ZooKeeper and XIcon. I personally prefer ZooKeeper for these sorts of relatively simple tasks – XIcon is useful when you want to create a shortcut from a shell script, while ZooKeeper tends work best for single-line terminal commands.

To get started, you first need to have the ZooKeeper software installed – it’s available on BeBits if you don’t have it already. ZooKeeper comes with several sample apps – one to open files in EMACS, one to open files in PICO, etc. The easiest route is to simply duplicate one of the sample apps – such as EmacsOpener – by right-clicking on the icon and selecting “Duplicate.” You’ll now have a file called something like “EmacsOpener copy” – you may wish to rename it to something like “AspellChecker” so it’s easier to identify.

Now double-click on the icon to begin configuring your new ZooKeeper app. Configuring ZooKeeper to send files to aspell is pretty straightforward. First, you’ll need to change the text in the “Command” field – change it to the following:

/boot/apps/aspell/aspell check $zkfiles

Next, erase any text from the “Working dir” field – a working directory isn’t needed with aspell. Now make sure that there *is* a checkmark in the box beside the words
“In Terminal,” and make sure there *is not* a checkmark beside “Keep Open.” Lastly, click on the “Edit Supported Filetypes” button. Look for the words “Supported Types” – if one of the types listed is “text” or “Text File,” then you do not need to make any changes. That should the case if you modified EmacsOpener or PicoOpener, as they are already configured to support plain text files.

If you do not see “text” or “Text File” in the list of supported types, then click the “Add” button. A list of application types will appear – click the triangle next to the word “text,” and then scroll down until you see an item called “Text File.” Click on it and then click the “Add” button – “Text File” should now be visible in the Supported Types list. You can now close the Application Type window and the ZooKeeper window. Now it’s time to test the icon – you can do that by simply dragging-and-dropping a text file onto it. With any luck, aspell should then open in a terminal window and begin spell checking your file.

As with the Pe extension, if you prefer to download a working copy instead of creating it yourself, I’ve made a zip file available for download here. To install, just unzip the file and place it on your Desktop.

The ideal situation, of course, would be for developers of third-party BeOS / ZETA software to make use of aspell as a library in their software and provide a full graphical interface to it. It’s also probably possible to integrate aspell directly into Haiku, providing system-wide spell checking services (as in OS X). Until then, however, hopefully these tips will help make aspell a bit more convenient to use.

Category: guides   -   Comments RSS   -   Post a Comment   -   Trackback  

« »